'''
Created on Oct 2, 2011

@author: conan1154
'''
import dabo.biz

class ClientBizobj(dabo.biz.dBizobj):
    
    def afterInit(self):
        self.DataSource = "clients"
        self.KeyField = "pkid"
        self.addFrom("client")
        self.addField("clientname")
        self.addField("attn")
        self.addField("rate")
        self.addField("street1")
        self.addField("street2")
        self.addField("city")
        self.addField("stateprov")
        self.addField("postalcode")

    def validateRecord(self):
        """Returning anything other than an empty string from
        this method will prevent the data from being saved.
        """
        ret = ""
        # Add your business rules here.
        return ret
        
    def getNamesAndKeys(self):
        crs = self.getTempCursor()
        crs.execute("""select pkid, clientname
                from clients
                order by clientname""")
        ds = crs.getDataSet()
        
        names = [rec["clientname"] for rec in ds]
        keys = [rec["pkid"] for rec in ds]
        return (names, keys)